/**
 * 
 */
package wong.board.client.widgets;

import com.google.gwt.safehtml.client.HasSafeHtml;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasText;

/**
 * @author wong
 * 
 */
public class Label extends Component implements HasText, HasHTML, HasSafeHtml {

	public Label() {
		this("");
	}

	public Label(String text) {
		this.setStyleName(css.label());
		setText(text);
	}

	@Override
	public void setHTML(SafeHtml html) {
		this.getElement().setInnerHTML(html.asString());
	}

	@Override
	public String getHTML() {
		return this.getElement().getInnerHTML();
	}

	@Override
	public void setHTML(String html) {
		setHTML(SafeHtmlUtils.fromTrustedString(html));
	}

	@Override
	public String getText() {
		return this.getElement().getInnerText();
	}

	@Override
	public void setText(String text) {
		this.getElement().setInnerText(text);
	}

}
